/**
 * @author Eric Jahn
 * Course: Object Oriented Programming
 * Final Project
 * Due Date: August 3, 2012
*/
package oop.chat.connection;

import java.io.Serializable;
import java.util.ArrayList;
import oop.chat.user.UserAccount;

/**
 * request object for communication between server and client
 * @author Eric Jahn
 */
public class Request implements Serializable
{
	//type of the request
	private RequestType type;
	//user who sent the request
	private UserAccount user;
	//parameter array
	private ArrayList<Object> parameter;
	
	/**
	 * creates a new request
	 * @param	type		RequestTyoe
	 * @param	user		UserAccount
	 * @param	parameter	Object[]
	 */
	public Request(RequestType type, UserAccount user, ArrayList<Object> parameter)
	{
		this.type = type;
		this.user = user;
		this.parameter = parameter;
	}
	
	/**
	 * gets the request type
	 * @return	type		RequestTyoe
	 */
	public final RequestType getRequestType()
	{
		return this.type;
	}
	
	/**
	 * gets the user of the request
	 * @return	user		UserAccount
	 */
	public final UserAccount getUserAccount()
	{
		return this.user;
	}
	
	/**
	 * gets the parameter array of the request
	 * @return	parameter		Object[]
	 */
	public final ArrayList<Object> getParameter()
	{
		return this.parameter;
	}
	
	/**
	 * adds a parameter to the array list
	 * @param	parameter		Object
	 * @return	this			Request
	 */
	public Request addParameter(Object parameter)
	{
		this.parameter.add(parameter);
		return this;
	}
        
        public String toString()
        {
            StringBuffer buffer = new StringBuffer();
            buffer.append(type);
            buffer.append(" ");
            buffer.append(user);
            buffer.append(" ");
            buffer.append(parameter);
            
            return buffer.toString();
        }
}